/**
 * <p>Title: ServiceZM98.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-12-12 上午03:20:26  张志芳  Create
 *</pre>
 */
package com.baosight.sczx.zm.service;

import java.util.HashMap;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;

/**
 * 需求计划和领料申请
 * <p>Title: ServiceZM98.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-12-12 上午03:20:26  张志芳  Create
 *</pre>
 */
public class ServiceZM98 extends ServiceEPBase {

	/**
	 * 初始化
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZM98</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-12-12上午05:46:05 张志芳
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) {		
		return query(inInfo);		
	}
	
	/**
	 * 查询
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZM98</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-12-12上午05:46:13 张志芳
	 * </p>
	 *
	 */
	@Override
	public EiInfo query(EiInfo inInfo) {
		EiInfo outInfo = new EiInfo();
		outInfo.addBlock("planResult").addBlockMeta(getMeta());
		Map map = new HashMap();
		map.put("fdYear", StaticTools.getYear());
		map.put("fdMonth", Integer.parseInt(StaticTools.getMonth()));
		outInfo.getBlock("planResult").addRows(dao.query("ZM98.queryPlan", map));
		
		outInfo.addBlock("appResult").addBlockMeta(getMeta());
		outInfo.getBlock("appResult").addRows(dao.query("ZM98.queryApp", map));
		return outInfo;
	}
	
	
	/**
	 * 构造列
	 * <p>Function: getMeta</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlockMeta</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-12-12上午05:46:20 张志芳
	 * </p>
	 *
	 */
	private EiBlockMeta getMeta()
	{
		EiBlockMeta eiMetadata = new EiBlockMeta();
		EiColumn eiColumn = new EiColumn("item");
		eiColumn.setFieldLength(100);	
		eiColumn.setDescName("项目");
		eiMetadata.addMeta(eiColumn);
		
		eiColumn = new EiColumn("value");
		eiColumn.setFieldLength(8);	
		eiColumn.setDescName("值（个）");
		eiMetadata.addMeta(eiColumn);
		
		return eiMetadata;
	}
}
